﻿@model XPressify.Models.PostCommentModel
 
 <script type="text/javascript">
     var defaultTxt = "Write a comment...";
     function removeTextComment(comment) {
         comment.value = "";
         comment.style.color = "black";
     }
     function putTextComment(comment) {
         if (comment.value == "") {
             var oldText = document.getElementById("myTxt");
             comment.style.color = "#666";
             comment.value = defaultTxt;
         }
     }

     function success() {
         $(".newPostCommentClass").show("fast");
         $('.nobtn').css('color', 'blue');
         $('#ContentText').val("");
         $('#ContentText').focus();
     }
</script>

@*@using (Html.BeginForm("PostComment", "Post", FormMethod.Post))*@

@using (Ajax.BeginForm("PostComment", "Post", new AjaxOptions() { OnSuccess ="success", HttpMethod = "POST" ,UpdateTargetId = Model.PostId.ToString()+"Update", InsertionMode = InsertionMode.InsertAfter, }))
{
    <table border="0" cellpadding="0" cellspacing="0" style="margin:0px;padding:0px;width:553px;background-color: #E8EEF4;">
        <tr>
            <td style="padding: 0px 2px 0px 2px;width:93px" align="right">
                <a href='@Url.Action("ProfileView", "Profile", new { id = Model.PostId })' class="nobtn">
                    <img src= "@Model.ProfilePicturePath" alt="Profile picture" title="Profile picture" style="width: 35px;height: 35px;" align="right"/> 
                </a>
            </td>
            <td style="padding: 0px 2px 0px 2px;border-spacing: 0px 0px;">
                @Html.TextAreaFor(model => model.ContentText, 2, 52, new { style = "resize: none;color: #666;vertical-align:bottom", onclick = "removeTextComment(this)", onblur = "putTextComment(this)" }) 
            </td>
        </tr>
        
        <tr>
            <td style="padding: 0px 2px 0px 2px;"></td>
            <td style="padding: 0px 2px 0px 363px" align="left">
                <input type="submit" value="Comment" />
            </td>
        </tr>
    </table>
    @Html.HiddenFor(model => model.PostId)
}